export const set = (key, data) => {
  if (data == null) return
  const type = typeof data
  let dataStr
  if (type === 'object') {
    dataStr = '1' + JSON.stringify(data)
  } else {
    dataStr = '0' + data
  }
  localStorage.setItem(key, dataStr)
}

export const get = (key) => {
  const dataStr = localStorage.getItem(key)
  if (dataStr) {
    if (dataStr.startsWith('1')) {
      return JSON.parse(dataStr.slice(1))
    } else {
      return dataStr.slice(1)
    }
  }
}

export const remove = (key) => {
  console.log('localStorage.removeItem', key)
  return localStorage.removeItem(key)
}
